# Maintainer: Jonas Witschel <diabonas@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
pkgname=bcprov
pkgver=1.73
pkgrel=1
pkgdesc='Bouncy Castle Crypto APIs for Java'
arch=('any')
url='https://www.bouncycastle.org/java.html'
license=('MIT')
depends=('java-runtime-headless')
makedepends=('git' 'ant' 'strip-nondeterminism')
source=("$pkgname-$pkgver.tar.gz::https://github.com/bcgit/bc-java/archive/refs/tags/r${pkgver/./rv}.tar.gz")
sha512sums=('7d2abab42a7e29159ae063244a4296708d1269e5a8250f0e2f62b095916d509e6e4213f4b32d45f375e1aabea572860d9b81df9ee5efcdff9b9e569864c9f8db')

build() {
	cd "bc-java-r${pkgver/./rv}"
	ant -f ant/jdk18+.xml clean build-provider build

	# Timestamps in JAR files generated by Ant do not honour SOURCE_DATE_EPOCH
	# (https://bz.apache.org/bugzilla/show_bug.cgi?id=61269)
	strip-nondeterminism --timestamp "$SOURCE_DATE_EPOCH" "build/artifacts/jdk1.8/jars/bcprov-jdk18on-${pkgver/./}.jar"
}

check() {
	cd "bc-java-r${pkgver/./rv}"
	ant -f ant/jdk18+.xml test
}

package() {
	cd "bc-java-r${pkgver/./rv}"
	install -Dm644 "build/artifacts/jdk1.8/jars/bcprov-jdk18on-${pkgver/./}.jar" -t "$pkgdir/usr/share/java/$pkgname"
	ln -s "bcprov-jdk18on-${pkgver/./}.jar" "$pkgdir/usr/share/java/$pkgname/bcprov.jar"
	install -Dm644 LICENSE.html -t "$pkgdir/usr/share/licenses/$pkgname"
}
